package cn.com.czpb.client.module.news.activity;

import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

import com.gyf.barlibrary.ImmersionBar;
import com.uuzuche.lib_zxing.activity.CodeUtils;

import cn.com.czpb.client.R;
import cn.com.czpb.client.app.ToolBarActivityWhite;
import cn.com.czpb.client.module.personal.WodeFragment;
import cn.com.czpb.client.utils.LogUtils;
import cn.com.czpb.client.utils.PageCtrl;
import cn.com.czpb.client.utils.TUtils;

public class Home_MyActivity extends ToolBarActivityWhite {
    private WodeFragment fragment;
    private FragmentManager fm;
    @Override
    public int setMyContentView() {
        return R.layout.activity_home__my;
    }

    @Override
    public void initView() {
        super.initView();
        mImmersionBar = ImmersionBar.with(this);
        mImmersionBar.statusBarDarkFont(true).init();
        fragment=new WodeFragment();
        fm=getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.home_my, fragment);
        ft.commit();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        LogUtils.i("requestCode-->"+requestCode);
        LogUtils.i("resultCode-->"+resultCode);
            //处理扫描结果（在界面上显示）
            if (null != data) {
                LogUtils.i("data-->"+data);
                Bundle bundle = data.getExtras();
                if (bundle == null) {
                    return;
                }
                if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_SUCCESS) {
                    String url = bundle.getString(CodeUtils.RESULT_STRING);
                    PageCtrl.start2HtmlSaoActivity(activity,url);
                } else if (bundle.getInt(CodeUtils.RESULT_TYPE) == CodeUtils.RESULT_FAILED) {
                    TUtils.toast("解析二维码失败");
                }
            }
    }
}
